package com.yami.shop.api.controller.tudu;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yami.shop.bean.model.tudu.ShoppingCart;
import com.yami.shop.dao.tudu.ShoppingCartMapper;
import com.yami.shop.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/p/shoppingCart")
@Api(tags = "大购物车接口")
public class ShoppingCartController {

    @Autowired
    private ShoppingCartMapper shoppingCartMapper;

    @GetMapping("/query")
    @ApiOperation(value = "查询大购物车商品", notes = "查询大购物车商品")
    public ResponseEntity<List<ShoppingCart>> query(){
        String userId = SecurityUtils.getUser().getUserId();
            List<ShoppingCart> shopp = shoppingCartMapper.selectList(new LambdaQueryWrapper<ShoppingCart>()
            .eq(ShoppingCart::getUserId,userId));
            return ResponseEntity.ok(shopp);
    }
}
